#!/usr/bin/env python
"""
# -*- coding: utf-8 -*-
# @Time    : 2020/9/23 19:16
# @Author  : AshJo
# @Desc    : 多态
# @Filename: polymorphism.py
# @Version : v1.0
"""

# 多态和鸭子类型

"""
一个对象有效的语义，不是由继承自特定的类或实现特定的接口，而是由"当前方法"方法 (计算机科学)")和属性的集合"决定
"""


class Animal(object):

    def run(self):
        print("The animal is running...")


class Dog(Animal):

    def run(self):
        print('The dog is running...')


class Cat(Animal):

    def run(self):
        print('The cat is running...')


class Person(object):
    def run(self):
        print("The person is running...")


def makeRun(animalType):
    animalType.run()


dog = Dog()
cat = Cat()
makeRun(dog)
makeRun(cat)

person = Person()
makeRun(person)
